#include <REGX52.H>
#include "DS18B20.h"
#include "usart.h"

float T;


void Delay(unsigned int xms)
{
	unsigned char i, j;
	while(xms--)
	{
		i = 2;
		j = 239;
		do
		{
			while (--j);
		} while (--i);
	}
}

void SG(int a,int b)
{
    unsigned char Tab[]={0x3F,0x06,0x5B,0x4F,0x66,0x6D,0x7D,0x07,0x7F,0x6F,0x40};
    unsigned char Count[]={0x01,0x02};
	P2=Count[a];
	P0=Tab[b];
	Delay(6);
}

void main()
{
	 UART_Init();
		while(1)
		{
//			if(P1_0==0)
//			{
//				while(P1_0==1);
				DS18B20_ConvertT();		
//				Delay(1000);			
			
				DS18B20_ConvertT();	
				T=DS18B20_ReadT();	
				printf(T);
//				Delay(1000);	
//			}
			SG(1,(int)T/10);
			SG(0,(int)T%10);
	}
}

